package org.will.demo;

import org.will.demo.application.MQDemoService;

import java.util.Date;

public class Main {

    public static void main(String[] args) throws Exception {

        MQDemoService service = new MQDemoService();
        System.out.println("Start Time:" + new Date().toString());
        long timeStartStamp = System.currentTimeMillis() / 1000;
        service.startup();
        long timeEndStamp = System.currentTimeMillis() / 1000;
        System.out.println("Cost:" + (timeEndStamp-timeStartStamp));
        System.out.println("End Time:" + new Date().toString());
//        service.createMQDemo("lee");
//        service.createMQDemo("will");
        service.updateMQDemo(1L,"CC",10d,11d);
//        for(int i=0;i<600_000;i++) {
//            service.createMQDemo("lee"+i);
//        }
        service.shutdown();
    }

//    private void initDemo1(Reveno reveno)
//    {
//        DynamicCommand createMQDemo = reveno.domain()
//                .transaction("createMQDemo",
//                        (t, c) -> c.repo().store(t.id(), new MQDemo(t.arg())))
//                .uniqueIdFor(MQDemo.class).command();
//        reveno.startup();
//        Map<String, Object> map = new HashMap<String, Object>();
//        map.put("_ename", "will");
//        //long moqDemoId = reveno.executeSync(createMQDemo, map);
//
//        if (reveno.query().find(MQDemoView.class, 1)._ename.equals("will")) {
//            System.out.print("aaaaa");
//        }
//    }
//
//    private void initDemo2(Reveno reveno)
//    {
//        reveno.domain().command(CreateMQDemoCommand.class, CreateMQDemoCommand::handleCommand);
//        reveno.domain().transactionAction(CreateMQDemoCommand.CreateMQDemoCommandAction.class, (a, ctx) ->
//        {
//            ctx.repo().store(a._id, new MQDemo(a._cmd._ename));
//            System.out.println(a._id);
//            ctx.eventBus().publishEvent(new MQDemoCreateEvent(a._id));
//        });
//        reveno.domain().viewMapper(MQDemo.class, MQDemoView.class, (e, c, r) -> new MQDemoView(e, c._ename));
//        reveno.startup();
//        reveno.executeSync(new CreateMQDemoCommand("will"));
//        reveno.shutdown();
//        System.out.println(reveno.query().find(MQDemoView.class, 1));
//        System.out.println(reveno.query().find(MQDemoView.class, 2));
//
//    }
}
